<?php
ob_start();
session_start();
include "inc/config.php";
if(isset($_SESSION['id']))
{
	$user = $userClass->user; 
	$authority = new UserGroup($db);
}
else
{
	echo 'Session Error. Please Reload Page.';
	die;
} 

if(isset($_POST['islem']))
{
	switch($_POST['islem'])
	{
		case 'delete_comments':
		{
			$hata = array('sonuc'=>true,'aciklama'=>'Undefined.');
			if($authority->getAuthority("delete_comments",$_SESSION['id']))
			{
				if(isset($_POST['cid']))
				{
					$commentDelQuery = file_get_contents("https://graph.facebook.com/".$_POST['cid']."?method=delete&access_token=".TOKEN);
					if($commentDelQuery == 'true')
					{
						$hata['sonuc'] = true;
						$hata['aciklama'] = 'Yorum Başarıyla Silindi.';
						$log->log($_SESSION['id'],' Comments Deleted. ID:'.$_POST['cid']);
					}
				}
				else
				{
					$hata['sonuc']= false;
					$hata['aciklama'] = ' Query Method not defined. Please contact administrator.';
				}
			}
			else
			{
				$hata['sonuc'] = false;
				$hata['aciklama'] = 'You Cant Delete Comments!';
			}
			
			if($hata['sonuc'] == false)
			{
				echo $hata['aciklama'];
			}
		}
		break;
	}
}
?>

